package com.yjhb.android.sbz.mvp.behavior;

import com.yjhb.android.sbz.entity.UserBehavior;
import com.yjhb.android.sbz.http.HttpObserver;
import com.yjhb.android.sbz.http.HttpTool;
import com.yjhb.android.sbz.mvp.ConventionPresenter;

/**
 * 创建者 zx
 * 创建时间 2020/12/30 16:02
 */
public class BehaviorPresenter extends ConventionPresenter<BehaviorView> {
    private final String TAG = "SharePresenter";

    @Override
    protected void onDestroy() {

    }

    public BehaviorPresenter(BehaviorView behaviorView) {
        super(behaviorView);
    }


    /**
     * shareType:分享类型：1、分享到朋友圈；2、分享给微信好友；3、QQ分享；4、连接分享
     */
    public void addUserBehaviorCount(Integer type) {
        if (view != null) {
            view.onWait();
        }
        HttpTool.request(model.addUserBehaviorCount(type), new HttpObserver<Object>() {
            @Override
            public void onResult(Object data) {
                if (view != null) {
                    view.onSuccess(data);
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (view != null) {
                    view.onFailure(code, msg);
                }
            }
        });
    }


    /**
     * 获取用户行为
     */
    public void getTotalTaskBehavior() {
        if (view != null) {
            view.onWait();
        }
        HttpTool.request(model.getTotalTaskBehavior(), new HttpObserver<UserBehavior>() {
            @Override
            public void onResult(UserBehavior data) {
                if (view != null) {
                    view.onSuccess(data);
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (view != null) {
                    view.onFailure(code, msg);
                }
            }
        });
    }

}
